
package com.enlorenz.core.channel.socket.common.reader;

import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

import com.enlorenz.core.channel.socket.common.util.NioUtil;

/**
 * 带长度的格式的报文读取类器
 * @author lcb
 */
public class LengthBodyNioReader extends AbstractLengthBodyReader implements INioReader{
	private SocketChannel channel;
	private ByteBuffer commBuffer;
	
	@Override
	protected byte[] readLength(int length) throws Exception {
		byte [] msgBody=NioUtil.read(channel, commBuffer, length);
		return msgBody;
	}

	public SocketChannel getChannel() {
		return channel;
	}

	public void setChannel(SocketChannel channel) {
		this.channel = channel;
	}

	public ByteBuffer getCommBuffer() {
		return commBuffer;
	}

	public void setCommBuffer(ByteBuffer commBuffer) {
		this.commBuffer = commBuffer;
	}
}
